<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>欢迎页面-L-admin1.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="../css/font.css">
    <link rel="stylesheet" href="../css/xadmin.css">
    <script src="../js/jquery.min.js"></script>
    <script type="text/javascript" src="../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
<h1 align="center" id="试卷名字">这里显示试卷名字作为标题</h1><br>
<h3 align="center" id="试卷难度加题量加分数">这里显示试卷难度&emsp;&emsp;&emsp;&emsp;这里显示试卷题目数量&emsp;&emsp;&emsp;&emsp;这里显示试卷总分</h3><br>
<div class="x-body">
    <div class="layui-collapse" lay-filter="test" id="test">
        <div class="layui-colla-item" id="整体"></div>
        <b id="题目内容"></b>
        <h2 class="layui-colla-title" style="font-size: 17px;display: none" id="题目内容显示框" ></h2>
        <div style="color: gray" id="题号"></div>
        <b id="题目答案"></b>
        <p style="font-size: 15px;color:lightslategray;" id="答案显示框"></p>
        <div class="layui-colla-content" id="下拉答案显示框"></div>
    </div>
</div>

<script type="text/javascript">
var id=parent.$("#Id").val();
var details;
var num;
$.ajax({
    url: "/exam/querybytstno",
    type : "post",
    async: false,
    dataType: "json",
    data : {tstNo:id},
    // contentType: "application/json",
    success: function (data) {
        console.log("请求成功");
        console.log(data);
         details=data.tstDetail;
         num=data.tstNum;
         document.getElementById("试卷名字").innerHTML=data.tstName;
        document.getElementById("试卷难度加题量加分数").innerHTML="试卷难度："+data.tstDif+"    试题数量："+data.tstNum
            +"   试卷总分："+data.tstScore;
    },
    error: function (data) {
        console.log("请求失败");
    }
});
var i=0;
var Nos = details.match(/\d+(\d+)?/g);
console.log(Nos);
console.log(Nos[1]);

for (i=0;i<num;i++){
    $.ajax({
        url: "/library/getprobyno",
        type : "post",
        async: false,
        dataType: "json",
        data : {proNo:Nos[i]},
        success: function (data) {
            var problem=document.getElementById("整体").cloneNode();

            var detail=document.getElementById("题目内容").cloneNode();
            var detailBox=document.getElementById("题目内容显示框").cloneNode();
            detailBox.style.display="block";
            var proNo=document.getElementById("题号").cloneNode();
            var ans=document.getElementById("题目答案").cloneNode();
            var ansBox=document.getElementById("答案显示框").cloneNode();
            var downBox=document.getElementById("下拉答案显示框").cloneNode();
            proNo.innerHTML="本题是题库第"+data.proNo+"题";
            detail.innerHTML=data.proDetail;

            detailBox.appendChild(detail);

            var ansNo=data.proAnsno;
            console.log(ansNo);
            $.ajax({
                url: "/library/getanswerbyproansno",
                type : "post",
                async: false,
                dataType: "json",
                data : {proAnsno:ansNo},
                success: function (data) {
                    ans.innerHTML=data.ansDetail;
                },
                error: function (data) {
                    console.log("请求失败");

                }
            });

            ansBox.appendChild(ans);
            downBox.appendChild(ansBox);

            problem.appendChild(detailBox);
            problem.appendChild(proNo);
            problem.appendChild(downBox);
            document.getElementById("test").appendChild(problem);
        },
        error: function (data) {
            console.log("请求失败");

        }
    });



}
</script>

</body>

</html>